<?php
/**
 * @Author: liuhongbin
 * @Email: 514660094@qq.com
 * @Date: 2019-02-12 16:15:10
 * @Description:
 * @LastEditors: liuhongbin
 * @LastEditTime: xxx
 */

namespace addons\gs_developer\controller;

use addons\gs_developer\model\DebugModel;
use addons\gs_developer\model\ExceptionModel;
use app\common\controller\AddonsController;
use app\common\services\facade\Addons;
use think\App;

class Exception extends AddonsController
{
    private ExceptionModel $model;

    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->model = new ExceptionModel();
    }

    public function index()
    {
        // 获取列表数据
        $res = $this->model->getPageList();
        return $this->success($res['count'], $res['data']);
    }

    public function clear()
    {
        $sql = "TRUNCATE  table __PREFIX__gs_developer_exception;";
        Addons::batchSql($sql);
        return $this->success('清空成功');
    }

    public function delete($id)
    {
        $this->model->where('id', $id)->delete();
        return $this->success('删除成功');
    }
}
